home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 January: Mac OS SDK / Dev.CD Jan 00 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / TextUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  11.1 KB  |  396 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        TextUtils.h
  3.  
  4.      Contains:    Text Utilities Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5+
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __TEXTUTILS__
  19. #define __TEXTUTILS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __NUMBERFORMATTING__
  25. #include <NumberFormatting.h>
  26. #endif
  27. #ifndef __STRINGCOMPARE__
  28. #include <StringCompare.h>
  29. #endif
  30. #ifndef __DATETIMEUTILS__
  31. #include <DateTimeUtils.h>
  32. #endif
  33.  
  34.  
  35.  
  36. #if PRAGMA_ONCE
  37. #pragma once
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_STRUCT_ALIGN
  49.     #pragma options align=mac68k
  50. #elif PRAGMA_STRUCT_PACKPUSH
  51.     #pragma pack(push, 2)
  52. #elif PRAGMA_STRUCT_PACK
  53.     #pragma pack(2)
  54. #endif
  55.  
  56. /*
  57.  
  58.     Here are the current System 7 routine names and the translations to the older forms.
  59.     Please use the newer forms in all new code and migrate the older names out of existing
  60.     code as maintainance permits.
  61.     
  62.     NEW NAME                    OLD NAMEs                    OBSOLETE FORM (no script code)
  63.  
  64.     FindScriptRun
  65.     FindWordBreaks                                            NFindWord, FindWord
  66.     GetIndString            
  67.     GetString
  68.     Munger
  69.     NewString                
  70.     SetString                
  71.     StyledLineBreak
  72.     TruncString
  73.     TruncText
  74.  
  75.     UpperString ($A054)            UprString, UprText
  76.     UppercaseText                SCUpperText (a only)        UpperText ($A456)
  77.     LowercaseText                                            LwrString, LowerText, LwrText ($A056)
  78.     StripDiacritics                                            StripText ($A256)
  79.     UppercaseStripDiacritics                                StripUpperText ($A656)
  80.  
  81.  
  82. */
  83.  
  84. /* Type for truncWhere parameter in TruncString, TruncText */
  85. typedef short                             TruncCode;
  86.  
  87. enum {
  88.                                                                 /* Constants for truncWhere argument in TruncString and TruncText */
  89.     truncEnd                    = 0,                            /* Truncate at end */
  90.     truncMiddle                    = 0x4000,                        /* Truncate in middle */
  91.     smTruncEnd                    = 0,                            /* Truncate at end - obsolete */
  92.     smTruncMiddle                = 0x4000                        /* Truncate in middle - obsolete */
  93. };
  94.  
  95.  
  96. enum {
  97.                                                                 /* Constants for TruncString and TruncText results */
  98.     notTruncated                = 0,                            /* No truncation was necessary */
  99.     truncated                    = 1,                            /* Truncation performed */
  100.     truncErr                    = -1,                            /* General error */
  101.     smNotTruncated                = 0,                            /* No truncation was necessary - obsolete */
  102.     smTruncated                    = 1,                            /* Truncation performed    - obsolete */
  103.     smTruncErr                    = -1                            /* General error - obsolete */
  104. };
  105.  
  106. typedef SInt8                             StyledLineBreakCode;
  107.  
  108. enum {
  109.     smBreakWord                    = 0,
  110.     smBreakChar                    = 1,
  111.     smBreakOverflow                = 2
  112. };
  113.  
  114.  
  115. struct ScriptRunStatus {
  116.     SInt8                             script;
  117.     SInt8                             runVariant;
  118. };
  119. typedef struct ScriptRunStatus            ScriptRunStatus;
  120.  
  121. struct BreakTable {
  122.     char                             charTypes[256];
  123.     short                             tripleLength;
  124.     short                             triples[1];
  125. };
  126. typedef struct BreakTable                BreakTable;
  127. typedef BreakTable *                    BreakTablePtr;
  128.  
  129. struct NBreakTable {
  130.     SInt8                             flags1;
  131.     SInt8                             flags2;
  132.     short                             version;
  133.     short                             classTableOff;
  134.     short                             auxCTableOff;
  135.     short                             backwdTableOff;
  136.     short                             forwdTableOff;
  137.     short                             doBackup;
  138.     short                             length;                        /* length of NBreakTable */
  139.     char                             charTypes[256];
  140.     short                             tables[1];
  141. };
  142. typedef struct NBreakTable                NBreakTable;
  143. typedef NBreakTable *                    NBreakTablePtr;
  144. /* The following functions are new names that work on 68k and PowerPC*/
  145. EXTERN_API( long )
  146. Munger                            (Handle                 h,
  147.                                  long                     offset,
  148.                                  const void *            ptr1,
  149.                                  long                     len1,
  150.                                  const void *            ptr2,
  151.                                  long                     len2)                                ONEWORDINLINE(0xA9E0);
  152.  
  153. EXTERN_API( StringHandle )
  154. NewString                        (ConstStr255Param         theString)                            ONEWORDINLINE(0xA906);
  155.  
  156. EXTERN_API( void )
  157. SetString                        (StringHandle             theString,
  158.                                  ConstStr255Param         strNew)                                ONEWORDINLINE(0xA907);
  159.  
  160. EXTERN_API( StringHandle )
  161. GetString                        (short                     stringID)                            ONEWORDINLINE(0xA9BA);
  162.  
  163. EXTERN_API( void )
  164. GetIndString                    (Str255                 theString,
  165.                                  short                     strListID,
  166.                                  short                     index);
  167.  
  168. #if CGLUESUPPORTED
  169. EXTERN_API_C( void )
  170. setstring                        (StringHandle             theString,
  171.                                  const char *            strNew);
  172.  
  173. EXTERN_API_C( StringHandle )
  174. newstring                        (const char *            theString);
  175.  
  176. EXTERN_API_C( void )
  177. getindstring                    (char *                    theString,
  178.                                  short                     strListID,
  179.                                  short                     index);
  180.  
  181. #endif  /* CGLUESUPPORTED */
  182.  
  183. EXTERN_API( StyledLineBreakCode )
  184. StyledLineBreak                    (Ptr                     textPtr,
  185.                                  long                     textLen,
  186.                                  long                     textStart,
  187.                                  long                     textEnd,
  188.                                  long                     flags,
  189.                                  Fixed *                textWidth,
  190.                                  long *                    textOffset)                            FOURWORDINLINE(0x2F3C, 0x821C, 0xFFFE, 0xA8B5);
  191.  
  192. EXTERN_API( short )
  193. TruncString                        (short                     width,
  194.                                  Str255                 theString,
  195.                                  TruncCode                 truncWhere)                            FOURWORDINLINE(0x2F3C, 0x8208, 0xFFE0, 0xA8B5);
  196.  
  197. EXTERN_API( short )
  198. TruncText                        (short                     width,
  199.                                  Ptr                     textPtr,
  200.                                  short *                length,
  201.                                  TruncCode                 truncWhere)                            FOURWORDINLINE(0x2F3C, 0x820C, 0xFFDE, 0xA8B5);
  202.  
  203. EXTERN_API( void )
  204. FindWordBreaks                    (Ptr                     textPtr,
  205.                                  short                     textLength,
  206.                                  short                     offset,
  207.                                  Boolean                 leadingEdge,
  208.                                  BreakTablePtr             breaks,
  209.                                  OffsetTable             offsets,
  210.                                  ScriptCode             script)                                FOURWORDINLINE(0x2F3C, 0xC012, 0x001A, 0xA8B5);
  211.  
  212. EXTERN_API( void )
  213. LowercaseText                    (Ptr                     textPtr,
  214.                                  short                     len,
  215.                                  ScriptCode             script)                                SIXWORDINLINE(0x3F3C, 0x0000, 0x2F3C, 0x800A, 0xFFB6, 0xA8B5);
  216.  
  217. EXTERN_API( void )
  218. UppercaseText                    (Ptr                     textPtr,
  219.                                  short                     len,
  220.                                  ScriptCode             script)                                SIXWORDINLINE(0x3F3C, 0x0400, 0x2F3C, 0x800A, 0xFFB6, 0xA8B5);
  221.  
  222. EXTERN_API( void )
  223. StripDiacritics                    (Ptr                     textPtr,
  224.                                  short                     len,
  225.                                  ScriptCode             script)                                SIXWORDINLINE(0x3F3C, 0x0200, 0x2F3C, 0x800A, 0xFFB6, 0xA8B5);
  226.  
  227. EXTERN_API( void )
  228. UppercaseStripDiacritics        (Ptr                     textPtr,
  229.                                  short                     len,
  230.                                  ScriptCode             script)                                SIXWORDINLINE(0x3F3C, 0x0600, 0x2F3C, 0x800A, 0xFFB6, 0xA8B5);
  231.  
  232. EXTERN_API( ScriptRunStatus )
  233. FindScriptRun                    (Ptr                     textPtr,
  234.                                  long                     textLen,
  235.                                  long *                    lenUsed)                            FOURWORDINLINE(0x2F3C, 0x820C, 0x0026, 0xA8B5);
  236.  
  237. /*
  238.       The following functions are old names, but are required for PowerPC builds
  239.       because InterfaceLib exports these names, instead of the new ones.
  240. */
  241.  
  242. EXTERN_API( void )
  243. FindWord                        (Ptr                     textPtr,
  244.                                  short                     textLength,
  245.                                  short                     offset,
  246.                                  Boolean                 leadingEdge,
  247.                                  BreakTablePtr             breaks,
  248.                                  OffsetTable             offsets)                            FOURWORDINLINE(0x2F3C, 0x8012, 0x001A, 0xA8B5);
  249.  
  250. EXTERN_API( void )
  251. NFindWord                        (Ptr                     textPtr,
  252.                                  short                     textLength,
  253.                                  short                     offset,
  254.                                  Boolean                 leadingEdge,
  255.                                  NBreakTablePtr         nbreaks,
  256.                                  OffsetTable             offsets)                            FOURWORDINLINE(0x2F3C, 0x8012, 0xFFE2, 0xA8B5);
  257.  
  258. /*
  259.    On 68K machines, LwrText, LowerText, StripText, UpperText and StripUpperText
  260.    return an error code in register D0, but System 7 PowerMacs do not emulate
  261.    this properly, so checking D0 is unreliable.
  262. */
  263.  
  264.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  265.                                                                                             #pragma parameter LwrText(__A0, __D0)
  266.                                                                                             #endif
  267. EXTERN_API( void )
  268. LwrText                            (Ptr                     textPtr,
  269.                                  short                     len)                                ONEWORDINLINE(0xA056);
  270.  
  271.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  272.                                                                                             #pragma parameter LowerText(__A0, __D0)
  273.                                                                                             #endif
  274. EXTERN_API( void )
  275. LowerText                        (Ptr                     textPtr,
  276.                                  short                     len)                                ONEWORDINLINE(0xA056);
  277.  
  278.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  279.                                                                                             #pragma parameter StripText(__A0, __D0)
  280.                                                                                             #endif
  281. EXTERN_API( void )
  282. StripText                        (Ptr                     textPtr,
  283.                                  short                     len)                                ONEWORDINLINE(0xA256);
  284.  
  285.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  286.                                                                                             #pragma parameter UpperText(__A0, __D0)
  287.                                                                                             #endif
  288. EXTERN_API( void )
  289. UpperText                        (Ptr                     textPtr,
  290.                                  short                     len)                                ONEWORDINLINE(0xA456);
  291.  
  292.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  293.                                                                                             #pragma parameter StripUpperText(__A0, __D0)
  294.                                                                                             #endif
  295. EXTERN_API( void )
  296. StripUpperText                    (Ptr                     textPtr,
  297.                                  short                     len)                                ONEWORDINLINE(0xA656);
  298.  
  299.  
  300. /* The following are new names which are exported by InterfaceLib*/
  301.  
  302. EXTERN_API( void )
  303. UpperString                        (Str255                 theString,
  304.                                  Boolean                 diacSensitive);
  305.  
  306. #if CGLUESUPPORTED
  307. EXTERN_API_C( void )
  308. upperstring                        (char *                    theString,
  309.                                  Boolean                 diacSensitive);
  310.  
  311. #endif  /* CGLUESUPPORTED */
  312.  
  313. /* The following are macros which map old names to the names exported by InterfaceLib*/
  314. #if OLDROUTINENAMES
  315. #define UprString(theString, diacSensitive)  \
  316.          UpperString(theString, diacSensitive)
  317. #if CGLUESUPPORTED
  318. #define uprstring(theString, diacSensitive) upperstring(theString, diacSensitive)
  319. #endif  /* CGLUESUPPORTED */
  320.  
  321. #endif  /* OLDROUTINENAMES */
  322.  
  323. /* Old routine name but no new names are mapped to it:*/
  324.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  325.                                                                                             #pragma parameter UprText(__A0, __D0)
  326.                                                                                             #endif
  327. EXTERN_API( void )
  328. UprText                            (Ptr                     textPtr,
  329.                                  short                     len)                                ONEWORDINLINE(0xA054);
  330.  
  331. /*
  332.  
  333.     Functions for converting between C and Pascal Strings
  334.     (Previously in Strings.h)
  335.     
  336. */
  337. EXTERN_API_C( StringPtr )
  338. c2pstr                            (char *                    aStr);
  339.  
  340. EXTERN_API( StringPtr )
  341. C2PStr                            (Ptr                     cString);
  342.  
  343. EXTERN_API_C( char *)
  344. p2cstr                            (StringPtr                 aStr);
  345.  
  346. EXTERN_API( Ptr )
  347. P2CStr                            (StringPtr                 pString);
  348.  
  349. EXTERN_API_C( void )
  350. c2pstrcpy                        (Str255                 dst,
  351.                                  const char *            src);
  352.  
  353. EXTERN_API_C( void )
  354. p2cstrcpy                        (char *                    dst,
  355.                                  ConstStr255Param         src);
  356.  
  357. EXTERN_API_C( void )
  358. CopyPascalStringToC                (ConstStr255Param         src,
  359.                                  char *                    dst);
  360.  
  361. EXTERN_API_C( void )
  362. CopyCStringToPascal                (const char *            src,
  363.                                  Str255                 dst);
  364.  
  365.  
  366. #if !TARGET_OS_MAC
  367.     /* Added for QuickTime 3.0 */
  368.     #define C2PStr(a)        (StringPtr)c2pstr((Ptr)(a))
  369.     #define P2CStr(a)        (Ptr)p2cstr(a)
  370.  
  371.     #define CopyPascalStringToC(src,dst) p2cstrcpy(dst,src)
  372.     #define CopyCStringToPascal(src,dst) c2pstrcpy(dst,src)
  373. #endif
  374.  
  375.  
  376. #if PRAGMA_STRUCT_ALIGN
  377.     #pragma options align=reset
  378. #elif PRAGMA_STRUCT_PACKPUSH
  379.     #pragma pack(pop)
  380. #elif PRAGMA_STRUCT_PACK
  381.     #pragma pack()
  382. #endif
  383.  
  384. #ifdef PRAGMA_IMPORT_OFF
  385. #pragma import off
  386. #elif PRAGMA_IMPORT
  387. #pragma import reset
  388. #endif
  389.  
  390. #ifdef __cplusplus
  391. }
  392. #endif
  393.  
  394. #endif /* __TEXTUTILS__ */
  395.  
  396.